//
//  Adaptive.m
//  测试
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 Sky. All rights reserved.
//

#import "Adaptive.h"

@implementation Adaptive
+(CGFloat)adaptiveHeightByString:(NSString *)string Width:(CGFloat)width FontSize:(NSInteger)fontSize
{
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:fontSize], NSFontAttributeName, nil];
    CGRect rect = [string boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    CGFloat height = rect.size.height + 1;
    return height;
}

+(CGFloat)adaptiveWidthByString:(NSString *)string Height:(CGFloat)height FontSize:(NSInteger)fontSize
{
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:fontSize], NSFontAttributeName, nil];
    CGRect rect = [string boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, height) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    CGFloat width = rect.size.width + 1;
    return width;
}
@end
